package com.project.dao.impl;

import java.util.List;

import com.project.dao.UserInfoDao;
import com.project.dao.bean.UserInfo;

/**
 * 后台 用户管理 Dao Impl
 * @author Sn
 *
 */
public class UserInfoDaoImpl extends BaseDaoImpl implements UserInfoDao 
{

	@Override
	public void update(UserInfo userInfo) throws Exception 
	{
		this.getSqlMapClient().update("updateUser", userInfo);
	}

	@Override
	public void save(UserInfo userInfo) throws Exception 
	{
		this.getSqlMapClient().insert("saveUser", userInfo);
	}

	@Override
	public List<UserInfo> getUserInfo() throws Exception 
	{
		List<UserInfo> list = this.getSqlMapClient().queryForList("getNewsUser");
        return list;
	}

	@Override
	public void delete(UserInfo userInfo) throws Exception 
	{
		this.getSqlMapClient().update("deleteUser", userInfo);
	}

	@Override
	public List<UserInfo> getUserInfo(UserInfo userInfo) throws Exception 
	{
		List<UserInfo> list = this.queryWithPg("queryUserByPg", userInfo);
		return list;
	}

	@Override
	public UserInfo getUserById(UserInfo userInfo) throws Exception 
	{
		return (UserInfo)this.getSqlMapClient().queryForObject("getUserById",userInfo);
	}

	@Override
	public boolean check(String loginName) throws Exception 
	{
		int i = (Integer)this.getSqlMapClient().queryForObject("checkLoginName",loginName);
		System.out.println("I~~"+i);
		if(i==0)
		{
			return true;
		}
		return false;
	}

}
